<template>
  <div id="page-setting">
    <topHeader title="设置"></topHeader>
    <div class="setting">
      <group>
        <x-switch title="接收消息" v-model="receive" @on-change="changeStatus()" style="display:none"></x-switch>
        <cell title="用户协议"  is-link class="user-agreement" @click.native="btn_agreement"></cell>
        <cell title="用户隐私政策"  is-link class="user-agreement" @click.native="btn_privacy"></cell>
        <cell title="检查更新"  is-link class="check-update" @click.native="btn_update"></cell>
         <cell title="版本号" :value="version" class="version" ></cell>
      </group>
      
      <div class="receive"></div>
      <div class="user-agreement"></div>
      <div class="version"></div>
    </div>
  </div>
</template>
<script>
import topHeader from '@/components/topHeader'
import { XSwitch,Group,Cell } from 'vux'
import toolFun from '@/assets/js/tool.js'
import update from '@/assets/js/update.js'
export default {
  data() {
    return {
      receive: this.$store.state.receiveMessage,
      version: 'V1.0.4'
    }
  },
  components: {
    topHeader,
    XSwitch,
    Group,
    Cell
  },
  methods: {
    // 改变接受消息开关状态函数
    changeStatus() {
      this.$store.state.receiveMessage = !this.$store.state.receiveMessage
      console.log(this.$store.state.receiveMessage)
    },
    // 跳转用户隐私政策
    btn_privacy() {
      this.$router.push('/userPrivacy')
    },
    // 跳转用户协议
    btn_agreement() {
      this.$router.push('/userAgreement')
    },
    // 检查更新
    btn_update() {
      // toolFun.checkUpadte(this)
      update.updateVersion(this, window, true)
    }
  }
}
</script>
<style lang="less">
  @import './index.less';
</style>
